package com.hotel.management.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 系统健康检查控制器
 * 用于验证系统是否正常启动和运行
 * 
 * @author Hotel Management Team
 * @version 1.0.0
 * @since 2024-06-27
 */
@RestController
@RequestMapping("/health")
public class HealthController {

    /**
     * 系统健康检查接口
     * 
     * @return 系统状态信息
     */
    @GetMapping
    public Map<String, Object> health() {
        Map<String, Object> result = new HashMap<>();
        result.put("status", "UP");
        result.put("message", "酒店管理系统运行正常");
        result.put("timestamp", new Date());
        result.put("version", "1.0.0");
        result.put("application", "hotel-management-system");
        return result;
    }

    /**
     * 系统信息接口
     * 
     * @return 系统详细信息
     */
    @GetMapping("/info")
    public Map<String, Object> info() {
        Map<String, Object> result = new HashMap<>();
        result.put("application", "酒店管理系统");
        result.put("version", "1.0.0");
        result.put("description", "基于Spring Boot的企业级酒店管理解决方案");
        result.put("author", "Hotel Management Team");
        result.put("buildTime", "2024-06-27");
        result.put("javaVersion", System.getProperty("java.version"));
        result.put("springBootVersion", "2.7.18");
        
        // 系统运行时信息
        Runtime runtime = Runtime.getRuntime();
        Map<String, Object> systemInfo = new HashMap<>();
        systemInfo.put("totalMemory", runtime.totalMemory() / 1024 / 1024 + " MB");
        systemInfo.put("freeMemory", runtime.freeMemory() / 1024 / 1024 + " MB");
        systemInfo.put("maxMemory", runtime.maxMemory() / 1024 / 1024 + " MB");
        systemInfo.put("processors", runtime.availableProcessors());
        
        result.put("system", systemInfo);
        return result;
    }

    /**
     * 欢迎页面
     * 
     * @return 欢迎信息
     */
    @GetMapping("/welcome")
    public Map<String, Object> welcome() {
        Map<String, Object> result = new HashMap<>();
        result.put("message", "欢迎使用酒店管理系统！");
        result.put("description", "这是一个基于Spring Boot开发的现代化酒店管理解决方案");
        result.put("features", new String[]{
            "员工管理", "房间管理", "客户管理", "财务管理", "数据统计", "权限控制"
        });
        result.put("timestamp", new Date());
        return result;
    }
}
